//
//  EvmCell.m
//  Manage
//
//  Created by 杨康 on 2017/11/10.
//  Copyright © 2017年 杨康. All rights reserved.
//

#import "EvmCell.h"

@implementation EvmCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        
        
        self.imgView=[[UIImageView alloc]init];
        //可省略
        self.imgView.layer.masksToBounds=YES;
        self.imgView.layer.cornerRadius=4.0;
        //
        [self.contentView addSubview:self.imgView];
        self.imgView.backgroundColor=[UIColor colorE];

        
        
        
        
        
        self.nameLab=[[UILabel alloc]init];
        self.nameLab.textColor=[UIColor colorQ];
        self.nameLab.font=[UIFont systemFontOfSize:16];
        [self.contentView addSubview:self.nameLab];
        
        
        
        self.storeNameLab=[[UILabel alloc]init];
        self.storeNameLab.textColor=[UIColor color9];
        self.storeNameLab.font=[UIFont systemFontOfSize:12];
        [self.contentView addSubview:self.storeNameLab];
        
        
        self.brandLab=[[UILabel alloc]init];
        self.brandLab.textColor=[UIColor color6];
        self.brandLab.font=[UIFont systemFontOfSize:14];
        [self.contentView addSubview:self.brandLab];
        
        
        self.colorLab=[[UILabel alloc]init];
        self.colorLab.textColor=[UIColor color6];
        self.colorLab.font=[UIFont systemFontOfSize:14];
        [self.contentView addSubview:self.colorLab];
        
        self.stateLab=[[UILabel alloc]init];
        self.stateLab.font=[UIFont systemFontOfSize:12];
        [self.contentView addSubview:self.stateLab];
        
        
        self.lineLab=[[UILabel alloc]init];
        self.lineLab.backgroundColor=[UIColor colorF];
        [self.contentView addSubview:self.lineLab];
        
        
        
        
    }
    return self;
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    
    
    
    [self.imgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.centerY.mas_equalTo(self.contentView);
        //可省略
        make.size.mas_equalTo(CGSizeMake(50, 50));
        
    }];
    
    
    
    [self.nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(8);
        make.left.mas_equalTo(self.imgView.mas_right).mas_offset(10);
        
    }];
    
    [self.storeNameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.nameLab.mas_right).mas_offset(10);
        make.centerY.mas_equalTo(self.nameLab);
        
    }];
    
    
    
    
    
    [self.brandLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.nameLab);
        make.bottom.mas_equalTo(-8);
       
    }];
    
    
    [self.colorLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.brandLab.mas_right).mas_offset(15);
        make.centerY.mas_equalTo(self.brandLab);
    }];
    
    
    [self.stateLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.contentView);
        make.centerY.mas_equalTo(self.contentView);
    }];
    
    
    
    [self.lineLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.bottom.mas_equalTo(-0.5);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, 0.5));
    }];
    
    
}
-(void)setDataDic:(EvmData *)dataDic
{
    if (![NSString isNULLString:dataDic.image]) {
        self.imgView.image =[UIImage imageNamed:dataDic.image?dataDic.image:@""];
    }
    self.nameLab.text=dataDic.name?dataDic.name:@"";
    self.storeNameLab.text=dataDic.storeName?dataDic.storeName:@"";
    self.brandLab.text=dataDic.brand?dataDic.brand:@"";
    self.colorLab.text=dataDic.color?dataDic.color:@"";
    NSString *state=dataDic.state?dataDic.state:@"";
    if ([state isEqualToString:@"1"]) {
        
        
        
        self.stateLab.text=@"未审核";
        self.stateLab.textColor=[UIColor colorWithRed:253.0f/255.0f green:134.0f/255.0f blue:151.0f/255.0f alpha:1.0];
        
    }
    else if ([state isEqualToString:@"3"])
    {
        
        
        self.stateLab.text=@"已审核";
        self.stateLab.textColor=[UIColor colorQ];
    }
    else if ([state isEqualToString:@"2"])
    {
        
        
        self.stateLab.text=@"未通过";
        self.stateLab.textColor=[UIColor colorWithRed:253.0f/255.0f green:134.0f/255.0f blue:151.0f/255.0f alpha:1.0];
    }
    else if ([state isEqualToString:@"4"])
    {
        
        
        self.stateLab.text=@"报失中";
        self.stateLab.textColor=[UIColor colorWithRed:243.0f/255.0f green:185.0f/255.0f blue:45.0f/255.0f alpha:1.0];
    }else
    {
        
        
        self.stateLab.text=@" ";
        self.stateLab.textColor=[UIColor whiteColor];
    }
    
    _dataDic=dataDic;
}
@end
